<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			window.onload=function(){
      var checkAll=document.getElementById('All');
     
      var otherCheck=document.getElementById('othercheck');
      var div=document.getElementById('div');
      var    checkBox=div.getElementsByTagName('input');
      checkAll.onclick=function(){
              for(i=0;i<checkBox.length;i++){
                     checkBox[i].checked=true;
                 }
         }
    
     otherCheck.onclick=function(){
             for(i=0;i<checkBox.length;i++){
                     if(checkBox[i].checked==true){
                             checkBox[i].checked=false;
                         }
                     else{
                         checkBox[i].checked=true
                        }
                     
                 }
         }
 }
		</script>
	</head>
	<body id="checkall">
		<input type="button" id="All" value="全选"/><br />
  		<input type="button" id="othercheck" value="反选" /><br />
  		<div id="div">
      <input type="checkbox" /><br />
      <input type="checkbox" /><br />
      <input type="checkbox" /><br />
      <input type="checkbox" /><br />
      </div>
		
	</body>
</html>
